<template>
  <div class="index">
    <van-pull-refresh
      v-model="isLoading"
      @refresh="onRefresh"
      :loosing-text="tips"
      :pull-distance="80"
    >
      <div class="index_top">
        <div class="index_top_title">
          <h3 style="margin: 0">小砖护™共享医疗 无人药店</h3>
          <div class="index_top_weather">
            <div>江门</div>
            <div>17°C晴</div>
          </div>
        </div>
        <div class="index_top_swiper">
          <van-swipe class="my-swipe" :autoplay="3000" indicator-color="white">
            <van-swipe-item>
              <img
                src="https://mjcelainetop-guangdong.oss-cn-shenzhen.aliyuncs.com/filesAliyun/4_2.jpg"
                alt=""
              />
            </van-swipe-item>
            <van-swipe-item>
              <img
                src="https://mjcelainetop-guangdong.oss-cn-shenzhen.aliyuncs.com/filesAliyun/4_2.jpg"
                alt=""
              />
            </van-swipe-item>
            <van-swipe-item>
              <img
                src="https://mjcelainetop-guangdong.oss-cn-shenzhen.aliyuncs.com/filesAliyun/4_2.jpg"
                alt=""
              />
            </van-swipe-item>
            <van-swipe-item>
              <img
                src="https://mjcelainetop-guangdong.oss-cn-shenzhen.aliyuncs.com/filesAliyun/4_2.jpg"
                alt=""
              />
            </van-swipe-item>
          </van-swipe>
        </div>
      </div>
      <div class="index_middle">
        <patientServe v-if="getUserTypeIsPatient()" />
        <doctorServer v-else />
      </div>

      <div class="index_bottom">
        <skeleton />
      </div>
    </van-pull-refresh>
  </div>
</template>

<script>
import { mapGetters } from "vuex";
import doctorServer from "@/components/doctorComponents/homeIndex_middle/doctorService.vue";
import { Toast } from "vant";
import skeleton from "@/components/commonComponents/skeleton.vue";
import patientServe from "@/components/patientComponents/homeIndex_middle/patientServe.vue";
export default {
  name: "homeIndex",
  components: { patientServe, skeleton, doctorServer },
  data() {
    return {
      isLoading: false,
      tips: "放手吧, 你想要的东西在下面",
    };
  },
  created() {},
  methods: {
    ...mapGetters(["getUserTypeIsPatient"]),
    onRefresh() {
      setTimeout(() => {
        Toast("刷新成功");
        this.isLoading = false;
      }, 1000);
    },
  },
};
</script>

<style lang="scss" scope>
* {
  box-sizing: border-box;
}
.index {
  width: 100%;
  background-color: #fafafa;
  box-sizing: border-box;
  padding: 30px 15px;
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 40px;
  overflow-y: auto;
  &_top {
    &_swiper {
      margin-top: 20px;
      border-radius: 12px;
      border: 1px solid #ccc;
      overflow: hidden;
    }
    &_title {
      padding: 0 1px 0 15px;
      display: flex;
      justify-content: space-between;
      align-items: center;
      & h3 {
        font-size: 20px;
      }
    }
    &_weather {
      font-size: 14px;
      transform: translateY(10px);
    }
  }
  &_middle {
    margin: 30px 0;
  }
  &_bottom{
    box-sizing: border-box;
  }
}
.my-swipe {
  height: 160px;
}
.my-swipe .van-swipe-item {
  color: #fff;
  text-align: center;
  width: 100%;

  & img {
    width: 100%;
    object-fit: cover;
    height: 160px;
  }
}
.van-swipe__indicator--active {
  width: 20px;
  border-radius: 15px;
}
</style>
